package com.kichina.parking.controller.parking;

import com.kichina.parking.controller.base.DataResponse;
import com.kichina.parking.controller.base.RequestInfo;
import com.kichina.parking.controller.base.enums.BusinessType;
import com.kichina.parking.controller.parking.handler.AppParkingHandler;
import com.kichina.parking.service.logic.bean.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Surging
 * @version 1.0
 * @ClassName AppParkingController
 * @date 2022-09-20 16:59
 * @desc App请求远程停车管理服务(查询)
 */
@RestController
@RequestMapping("/parking/info")
@Slf4j
public class AppParkingController {

    private final AppParkingHandler appParkingHandler;

    public AppParkingController(AppParkingHandler appParkingHandler) {
        this.appParkingHandler = appParkingHandler;
    }

    @GetMapping("/gateList")
    @RequestInfo(model = "获取车场通道集合", businessType = BusinessType.QUERY)
    public DataResponse listParkingGate(@RequestParam(value = "code") String code) {
       List<ChannelInfoRecord> channelInfos = appParkingHandler.listParkingGate(code);
        return DataResponse.buildSuccess(channelInfos);
    }

    @GetMapping("/carRecordList")
    @RequestInfo(model = "获取车场车辆进出记录集合", businessType = BusinessType.QUERY)
    public DataResponse listCarRecord(@RequestParam(value = "code") String code) {
        List<ParkingRecord> parkingRecords = appParkingHandler.listCarRecord(code);
        return DataResponse.buildSuccess(parkingRecords);
    }

    @GetMapping("/carTypeList")
    @RequestInfo(model = "获取车辆类型", businessType = BusinessType.QUERY)
    public DataResponse listCarType(@RequestParam(value = "code") String code) {
        List<CarTypeRecord> carTypeRecords = appParkingHandler.listCarType(code);
        return DataResponse.buildSuccess(carTypeRecords);
    }

    @GetMapping("/cardTypeList")
    @RequestInfo(model = "获取车牌类型", businessType = BusinessType.QUERY)
    public DataResponse listCardType(@RequestParam(value = "code") String code) {
        List<LicensePlateTypeRecord> licensePlateTypeRecords = appParkingHandler.listCardType(code);
        return DataResponse.buildSuccess(licensePlateTypeRecords);
    }

    @GetMapping("/stationaryCarList")
    @RequestInfo(model = "获取固定车信息集合", businessType = BusinessType.QUERY)
    public DataResponse listChargeRecord(@RequestParam(value = "code") String parkId, @RequestParam(value = "carNumber", required = false) String carNumber) {
        List<WhitelistInfoRecord> chargeRecords = appParkingHandler.listChargeRecord(parkId, carNumber);
        return DataResponse.buildSuccess(chargeRecords);
    }

}
